package com.woniu.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.domain.CourseElectiveitem;
import com.woniu.domain.CourseManagementDTO;
import com.woniu.service.CourseElectiveitemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
/**
 * @author: ljj  <br/>
 * Date: 2021/6/8:12:12  <br/>
 * Description: 选课明细
 */

@RestController
@RequestMapping("/courseElectiveitem/")
public class CourseElectiveitemController {
    @Autowired(required = false)
    CourseElectiveitemService courseElectiveitemService;

    @RequestMapping("study")
    public PageInfo<CourseElectiveitem> getCourseElectiveitemByCid(Integer courseId ,Integer page,Integer pageSize){
        PageHelper.startPage(page,pageSize);
        List<CourseElectiveitem> courseElectiveitemByCid = courseElectiveitemService.getCourseElectiveitemByCid(courseId);
        PageInfo<CourseElectiveitem> pageInfo = new PageInfo<>(courseElectiveitemByCid);
        return pageInfo;
    }

    @RequestMapping("cstudy")
    public PageInfo<CourseElectiveitem> conditionalQuery(@RequestBody CourseManagementDTO<CourseElectiveitem> courseManagementDTO){
        PageHelper.startPage(courseManagementDTO.getPage(),courseManagementDTO.getPageSize());
        List<CourseElectiveitem> courseElectiveitems = courseElectiveitemService.conditionalQuery((CourseElectiveitem)courseManagementDTO.getObj());
        PageInfo<CourseElectiveitem> pageInfo = new PageInfo<>(courseElectiveitems);
        return pageInfo;
    }

    @RequestMapping("userxkxx")
    public PageInfo<CourseElectiveitem> getCourseElectiveitemByUserId(Integer userId,Integer page,Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<CourseElectiveitem> list = courseElectiveitemService.getCourseElectiveitemByUserId(userId);
        PageInfo<CourseElectiveitem> PageInfo = new PageInfo<>(list);
        return PageInfo;
    }
    @RequestMapping("cxkxx")
    public PageInfo<CourseElectiveitem> courseNameConditionQuery(@RequestBody CourseManagementDTO<CourseElectiveitem> courseManagementDTO) {
        PageHelper.startPage(courseManagementDTO.getPage(),courseManagementDTO.getPageSize());
        List<CourseElectiveitem> list = courseElectiveitemService.courseNameConditionQuery((CourseElectiveitem)courseManagementDTO.getObj());
        PageInfo<CourseElectiveitem> PageInfo = new PageInfo<>(list);
        return PageInfo;
    }
    @RequestMapping("delById")
    public int delById(Integer id){
        return courseElectiveitemService.delById(id);
    }
}
